package com.quasar.hpatient.dialog;

import android.app.Activity;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.quasar.hpatient.R;

import lib.quasar.base.dialog.BaseDialog;

/**
 * description: 删除
 * created by kalu on 2018/4/16 13:15
 */
public class DeleteDoubleDialog extends BaseDialog {

    public String title;
    private OnDialogChangeListener listener;

    public DeleteDoubleDialog(Activity activity, String title) {
        super(activity);
        this.title = title;
    }

    @Override
    public void show() {
        super.show();
//        setCanceledOnTouchOutside(false);
//        setCancelable(false);
    }

    @Override
    protected int initView() {
        return R.layout.layout_dialog_delete_double;
    }

    @Override
    protected void initData() {

        findViewById(R.id.dialog_delete_back).setOnClickListener(v -> cancel());
        TextView titleView = (TextView) findViewById(R.id.dialog_delete_title);
        titleView.setText(title);
        findViewById(R.id.dialog_delete_ok).setOnClickListener(v -> {

            if (null != listener) {
                listener.onDelete();
            }
            cancel();
        });
    }

    public void setHead(CharSequence str) {

        if (TextUtils.isEmpty(str)) return;
        TextView title = findViewById(R.id.dialog_delete_title);
        if (null == title) return;

        title.setText(str);
    }

    public void setInfo(String str) {

        if (TextUtils.isEmpty(str)) return;
        TextView info = findViewById(R.id.dialog_delete_info);
        if (null == info) return;

        info.setText(str);
    }

    public void closeInfo() {
        TextView info = findViewById(R.id.dialog_delete_info);
        if (null == info) return;
        info.setVisibility(View.GONE);
    }

    public void setOnDialogChangeListener(OnDialogChangeListener mListener) {
        this.listener = mListener;
    }

    public interface OnDialogChangeListener {
        void onDelete();
    }
}
